package com.test.aop;

/**
 * ThreadLocal为每个线程单独提供一份存储空间
 * 将ThreadLocal进行封装，便于代码的维护和迭代
 */
public class UserThreadLocal {
    /**
     * 存储用户信息
     */
    private static ThreadLocal<Long> userThread = new ThreadLocal<>();

    public static void set(Long userId) {
        userThread.set(userId);
    }

    public static Long getUser() {
        return userThread.get();
    }

    public static void remove() {
        userThread.remove();
    }
}